<template>
  <HomePannel :title="'新鲜好物'" :subTitle="'新鲜出炉 品质靠谱'">
      <template #right>
        <XtxMore></XtxMore>
      </template>
      <!-- 面板 -->
      <div ref="box" style="position: relative;height: 406px;">
<Transition name="fade">
      <ul v-if="list.length"  class="goods-list">
          <li v-for="item in list" :key="item.id">
              <router-link :to="`/product/${item.id}`">
              <img v-lazy="item.picture" alt="">
              <p class="name ellipsis">{{item.name}}</p>
            <p class="price">￥{{item.price}}</p>
              </router-link>
          </li>
      </ul>
      <!-- 骨架 -->
    <HomeSkeleton :bg="'#f0f9f4'" v-else></HomeSkeleton>
      </Transition>
      </div>
  </HomePannel>
</template>

<script>
import { useLayzyData } from '@/hooks'
import { findNew } from '@/api/home'
import { ref } from 'vue'
import HomePannel from './home-pannel.vue'
import HomeSkeleton from './home-skeleton.vue'

export default {
  components: {
    HomePannel,
    HomeSkeleton
  },
  setup () {
    // const list = ref([])
    const box = ref(null)
    // findNew().then(data => {
    //   list.value = data.result
    // })

    const list = useLayzyData(box, findNew)
    // debugger
    return { list, box }
  }
}
</script>

<style scoped lang="less">
.home-panel {
  background:#fff
}
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>
